const express=require('express')
const app=express()
// app.use(express.static(__dirname+'/static'))
app.use(express.static(__dirname))

//设置允许跨域访问该服务.
app.all('*', function (req, res, next) {
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Headers', 'Content-Type');
    res.header('Access-Control-Allow-Methods', '*');
    res.header('Content-Type', 'application/json;charset=utf-8');
    next();
});


app.listen(5005,(err)=>{
    if(!err){
       console.log('服务器启动了')
    }
})

app.get('/person',(req,res)=>{
    console.log('来了')
    res.send({
        name:'tom',
        age:18
    })
})